//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

import java.util.Arrays;

public class demo_976 {
    public demo_976() {
    }

    public static void main(String[] args) {
        int[] nums = new int[]{1, 2, 1, 10};
        System.out.println(largestPerimeter(nums));
    }

    public static int largestPerimeter(int[] nums) {
        Arrays.sort(nums);

        for(int max = nums.length - 1; max >= 2; --max) {
            if (nums[max - 1] + nums[max - 2] > nums[max]) {
                return nums[max] + nums[max - 1] + nums[max - 2];
            }
        }

        return 0;
    }
}
